#include <memory>
#include "TcpServer.hpp"
#include "Protocol.hpp"
#include "NetCal.hpp"

int main()
{
    InetAddr addr(8081, "0");

    //1、应用层
    std::unique_ptr<Cal> cal = std::make_unique<Cal>();

    //2、协议层
    std::unique_ptr<Protocol> protocol = std::make_unique<Protocol>(
        [&](Request req)->Response{
            return cal->Execute(req);
    });

    //3、服务层
    std::unique_ptr<TcpServer> server = std::make_unique<TcpServer>(addr, 
        [&](std::shared_ptr<Socket> sock, InetAddr addr)
    {
        protocol->GetRequest(sock, addr);
    });
    
    server->Start();
    return 0;
}